﻿using System.Collections.Generic;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Linq;

namespace ClientOverflow.DataObjects
{
    /// <summary>
    /// Answer class represents the Answers table in the database. The class maintains the answer information
    /// and in addition holds the relations to other entities - the question to which the answer belongs and
    /// the answer votes.
    /// </summary>
    [ActiveRecord]
    public class Answer : ActiveRecordLinqBase<Answer>
    {
        [PrimaryKey]
        public int ID { get; set; }

        [Property]
        public string Content { get; set; }

        [BelongsTo("UserID")]
        public User User { get; set; }
        
        [BelongsTo("QuestionID")]
        public Question Question { get; set; }

        [HasMany]
        public IList<AnswerUpVote> UpVotes { get; set; }

        [HasMany]
        public IList<AnswerDownVote> DownVotes { get; set; }
    }
}